﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SYcwpb.ViewModels;
using SYcwpb.Helpers;

namespace SYcwpb.Views
{
    /// <summary>
    /// CSVFileView.xaml 的交互逻辑
    /// </summary>
    public partial class CSVFileView : Window
    {
        CSVFileViewModel viewModel ;

        public static CSVFileView _csvFileView  = null;

        private CSVFileView()
        {
            InitializeComponent();

            viewModel = new CSVFileViewModel(this);

            this.DataContext = viewModel;

            this.Closing += new System.ComponentModel.CancelEventHandler(CSVFileView_Closing);
        }

        void CSVFileView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //throw new NotImplementedException();
            if (viewModel.IsInserting)
                e.Cancel = true;
        }

        public static CSVFileView GetInStance()
        {
            if (null == _csvFileView || WindowHelper.IsDisposed(_csvFileView))
            {
                _csvFileView = new CSVFileView();
                
            }
            return _csvFileView;
        }
    }
}
